package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC991 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int brokenCalc(int startValue, int target) {
            int stepCnt = 0;
            while (target > startValue) {
                if (target % 2 == 0) {
                    target /= 2;
                    stepCnt++;
                } else {
                    target++;
                    stepCnt++;
                }
            }

            return stepCnt + Math.abs(target - startValue);
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.brokenCalc(2, 3));
        System.out.println(solution.brokenCalc(5, 8));
        System.out.println(solution.brokenCalc(3, 10));
    }

    public static void main(String[] args) throws Exception {
        LC991 an = new LC991();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
